package com.shqcjd.generalplatformprojectclient.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.shqcjd.generalplatformprojectclient.R;


public class SaveDraftDialog extends Dialog {
    private Context context;
    private setOnClickDialogListener listener;
    private Button btn_dialog_save, btn_dialog_finish;
    private TextView tv_dialog_save_title, tv_dialog_save_content;

    public void setOnClickDialogListener(setOnClickDialogListener listener){
        this.listener = listener;
    }


    public SaveDraftDialog(@NonNull Context context) {
        super(context);
        this.context = context;
    }

    public SaveDraftDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected SaveDraftDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_savedraft_dialog);
        getWindow().setBackgroundDrawableResource(R.color.transparent);
        btn_dialog_save = findViewById(R.id.btn_dialog_save);
        btn_dialog_finish = findViewById(R.id.btn_dialog_finish);
        tv_dialog_save_title = findViewById(R.id.tv_dialog_save_title);
        tv_dialog_save_content = findViewById(R.id.tv_dialog_save_content);

        btn_dialog_save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(listener!=null){
                    listener.onClickSave();
                }
            }
        });

        btn_dialog_finish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(listener!=null) {
                    listener.onClickFinish();
                }
            }
        });
    }

    public void setViewText(String title, String content, String save, String finish){
        tv_dialog_save_title.setText(title);
        tv_dialog_save_content.setText(content);
        btn_dialog_save.setText(save);
        btn_dialog_finish.setText(finish);
    }

    public interface setOnClickDialogListener{
        void onClickSave();
        void onClickFinish();
    }
}
